package com.maigu.dataobject;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.maigu.enums.OrderStatusEnum;
import com.maigu.enums.PayStatusEnum;

import com.maigu.utils.serializer.Date2Long;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;
@Entity
@Data
@DynamicUpdate
public class OrderMaster {
  @Id
  private String orderId;
  private String buyerName;
  private String buyerPhone;
  private String buyerAddress;
  private String buyerOpenid;
  private BigDecimal orderAmount;
  private Integer orderStatus= OrderStatusEnum.NEW.getCode();
  private Integer payStatus= PayStatusEnum.WAIT.getCode();
  //使用这个类转换时间
  @JsonSerialize(using= Date2Long.class)
  private Date createTime;
  @JsonSerialize(using= Date2Long.class)
  private Date updateTime;

  public OrderMaster() {
    super();
  }

  @Override
  public String toString() {
    return "OrderMaster{" +
            "orderId='" + orderId + '\'' +
            ", buyerName='" + buyerName + '\'' +
            ", buyerPhone='" + buyerPhone + '\'' +
            ", buyerAddress='" + buyerAddress + '\'' +
            ", buyerOpenid='" + buyerOpenid + '\'' +
            ", orderAmount=" + orderAmount +
            ", orderStatus=" + orderStatus +
            ", payStatus=" + payStatus +
            ", createTime=" + createTime +
            ", updateTime=" + updateTime +
            '}';
  }
}
